﻿using NHibernate;
using NHibernate.Criterion;
using NHibernate.SqlCommand;

namespace Myotragus.Data.Criteria
{
	public class LocalizableAlias : ILocalizableAlias
	{
		public virtual ICriteria CreateAlias(ICriteria criteria, string path, string alias,
			JoinType joinType, int lcId)
		{
			var prefix = string.IsNullOrEmpty(path) ? "" : string.Concat(path, ".");

			return criteria.CreateAlias(string.Concat(prefix, alias), alias, joinType,
					Restrictions.Eq(string.Format("{0}.LcId", alias), lcId));
		}
	}
}